package org.dingfugui.triple.common;

/**
 * Created by fugui.ding on 2015/6/9.
 */
public class LoggerFactory {

    static LoggerBuilder builder;

    static {
        try {
            Class.forName("org.apache.logging.log4j.Logger");
            builder = new LoggerBuilder() {
                @Override
                Logger build(String name) {
                    return new LoggerByLog4j2(name);
                }
            };
            System.out.println("使用log42");
        } catch (ClassNotFoundException e) {
            builder = new LoggerBuilder() {
                @Override
                Logger build(String name) {
                    return new LoggerByJdk(name);
                }
            };
            System.out.println("使用jdk logger");
        }
    }

    public static final Logger getLogger(String name) {
        return builder.build(name);
    }

    public static final Logger getLogger(Class<?> cls) {
        return getLogger(cls.getName());
    }

}
